﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.opttek.optquest;

namespace ConsoleApplication1
{
    class DesignMachine
    {
        public Machine machine;
        public Dictionary<int, string> materialKeys;

        public DesignMachine(Machine machine)
        {
            this.machine = machine;
            int i = 0;
            materialKeys = new Dictionary<int,string>();
            foreach (String m in machine.materials.Keys)
                materialKeys.Add(i++, m);

        }


        public double isMatProducing(COptQuestSolution sol, DesignVariable var, string matkey)
        {
            int v = (int)sol.GetVariableValue(var);
            if (v == -1)
                return 0;
            string key;
            try
            {
                 key = materialKeys[v];
        

            }
            catch (KeyNotFoundException)
            {
                return 0;
            }
            Materials m = machine.materials[key];
            if (m.material.Equals(matkey))
                return 1;
            return 0;
        }
    }
}
